<?php

class Admin_RealController extends Zend_Controller_Action
{

    public function init()
    {
        $this->_helper->layout->setLayout('admin/admin');
    }
    public  function indexAction(){

        $params['page'] = $this->_getParam('page', 1);
        $params['limit'] =20;
        $cache = Core_Global::getCache();
        $pages = ceil(count($cache->get('Real:ListIds')) / $params['limit']);
        $params['start'] = $params['page']*$params['limit'] - $params['limit'];
        $params['end'] = $params['start'] + $params['limit'];
        if($params['end']>count($cache->get('Real:ListIds'))){
            $end = count($cache->get('Real:ListIds'));
        }
        var_dump(Model_RealEstate::getAll($params));
    }

    public function createAction(){
        $customers = Model_Customer::getAllCustomers();
        $this->view->assign('customers', $customers);
        $realcategories = Model_RealCategory::getAllRealCategory();
        $this->view->assign('realcategories', $realcategories);
        $salecategories = Model_SaleCategory::getAllSaleCategory();
        $this->view->assign('salecategories', $salecategories);
        $posts = $this->_request->getPost();
        if($posts)
            $result = Model_RealEstate::create($posts);
        if($result)
            $this->view->assign('msg','Successful');
        else
            $this->view->assign('msg','Error');


    }



    public function updateAction(){

    }
    public function deleteAction(){

    }


}